/**
 * 系统所用到的常量、公共函数、方法、工具模块
 * @type {exports|module.exports}
 */

const DEBUG = true;

const Error = {
    "ERR001": "参数错误",
    "ERR002": "数据库异常",
    "ERR003": "数据格式解析失败"
}

let me = {

    MODEL_KEY:"MEXP_MODEL_KEY",


    success(data){
        return {
            code:0,
            data:data
        }
    },

    format(code, error){
        let data = {
            code: code,
            data: DEBUG?error:null,
            message: DEBUG ? Error[code] : "系统错误"
        };
        return data;
    },

    paramError(error){
        return this.format("ERR001", error);
    },

    sqlError(error){
        return this.format("ERR002", error);
    },

    dataError(error){
        return this.format("ERR003", error);
    }

}

module.exports = me;